package com.library.entity;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/*
* 员工类
* */

@Entity
@Table(name="staff")
public class Staff {
	private Integer staffId;			//ID
	private String username;			//用户名
	private String password;		//密码
	private String name;		//真实姓名
	private String email;		//邮箱
	private String qq;			//qq号码
	private String department;		//所属部门名称
	private int borrowedNumber;		//当前正在借阅数量
	private int maxBorrowNumber;		//最大可借数量
	private String staffSign;			//个人签名
	private Role role;		//角色
	private int grade;			//员工等级
	private String lastLoginTime;	//最后一次登录时间
	private boolean state;			//状态
	private Set<Evaluate> evaluates =new HashSet<Evaluate>();	//评论
	private Set<Borrow> borrows =new HashSet<Borrow>();	//借阅单
	private Set<Payment> payments =new HashSet<Payment>();	//缴费单
	private Set<Count> counts = new HashSet<>();		//数量统计
	private Set<Statistic> statistics = new HashSet<>();
    private Set<StaffSearch> staffSearches = new HashSet<>();
	private Set<StaffRelation> staffRelationsOne = new HashSet<>();
	private Set<StaffRelation> staffRelationsTwo = new HashSet<>();
	private Set<Book> books = new HashSet<>();
	private Collection collection;	//收藏夹
	private Circles circles;	//朋友圈
	private Recommendation recommendation;	//图书推荐
	private Set<Circles> followerCircles;			//从属粉丝列表
	private Set<Circles> followStaffsCircles;		//从属关注列表


	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Integer getStaffId() {
		return staffId;
	}
	public void setStaffId(Integer staffId) {
		this.staffId = staffId;
	}

	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}

	@Column(unique = true)
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(String lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}

	public int getGrade() {
		return grade;
	}

	public void setGrade(int grade) {
		this.grade = grade;
	}

	public String getDepartment() {
		return department;
	}

	public void setDepartment(String department) {
		this.department = department;
	}

	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public int getBorrowedNumber() {
		return borrowedNumber;
	}

	public void setBorrowedNumber(int borrowedNumber) {
		this.borrowedNumber = borrowedNumber;
	}

	public int getMaxBorrowNumber() {
		return maxBorrowNumber;
	}

	public void setMaxBorrowNumber(int maxBorrowNumber) {
		this.maxBorrowNumber = maxBorrowNumber;
	}

	@ManyToOne(cascade = CascadeType.PERSIST,fetch = FetchType.EAGER)
	@JoinColumn(name="roleId")
	public Role getRole() {
		return role;
	}
	public void setRole(Role role) {
		this.role = role;
	}

	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}

	public boolean isState() {
		return state;
	}

	public void setState(boolean state) {
		this.state = state;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="staffId")                       //指定与本类主键所对应的外表的外键
	public Set<Evaluate> getEvaluates() {
		return evaluates;
	}

	public void setEvaluates(Set<Evaluate> evaluates) {
		this.evaluates = evaluates;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="staffId")                       //指定与本类主键所对应的外表的外键
	public Set<Borrow> getBorrows() {
		return borrows;
	}

	public void setBorrows(Set<Borrow> borrows) {
		this.borrows = borrows;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="staffId")                       //指定与本类主键所对应的外表的外键
	public Set<Payment> getPayments() {
		return payments;
	}

	public void setPayments(Set<Payment> payments) {
		this.payments = payments;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="staffId")
	public Set<Count> getCounts() {
		return counts;
	}

	public void setCounts(Set<Count> counts) {
		this.counts = counts;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name="staffId")
	public Set<Statistic> getStatistics() {
		return statistics;
	}

	public void setStatistics(Set<Statistic> statistics) {
		this.statistics = statistics;
	}

    @OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
    @JoinColumn(name="staffId")
    public Set<StaffSearch> getStaffSearches() {
        return staffSearches;
    }
    public void setStaffSearches(Set<StaffSearch> staffSearches) {
        this.staffSearches = staffSearches;
    }

	@OneToOne(cascade = CascadeType.ALL,orphanRemoval = true)
	@JoinColumn(name="collectionId")
	public Collection getCollection() {
		return collection;
	}
	public void setCollection(Collection collection) {
		this.collection = collection;
	}


	@ManyToMany(cascade=CascadeType.PERSIST,fetch = FetchType.EAGER)
	@JoinTable(
			name="staffbookall",
			joinColumns={@JoinColumn(name="staffId")},
			inverseJoinColumns={@JoinColumn(name="bookId")})
	public Set<Book> getBooks() {
		return books;
	}

	public void setBooks(Set<Book> books) {
		this.books = books;
	}

	public String getStaffSign() {
		return staffSign;
	}

	public void setStaffSign(String staffSign) {
		this.staffSign = staffSign;
	}

	@OneToOne(cascade = CascadeType.ALL,orphanRemoval = true)
	@JoinColumn(name = "circlesId")
	public Circles getCircles() {
		return circles;
	}
	public void setCircles(Circles circles) {
		this.circles = circles;
	}


	@OneToOne(cascade = CascadeType.ALL,orphanRemoval = true)
	@JoinColumn(name = "recommendationId")
	public Recommendation getRecommendation() {
		return recommendation;
	}
	public void setRecommendation(Recommendation recommendation) {
		this.recommendation = recommendation;
	}


	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name ="staff2Id")
	public Set<StaffRelation> getStaffRelationsTwo() {
		return staffRelationsTwo;
	}
	public void setStaffRelationsTwo(Set<StaffRelation> staffRelationsTwo) {
		this.staffRelationsTwo = staffRelationsTwo;
	}

	@OneToMany(cascade=CascadeType.PERSIST,orphanRemoval = true)            //指定一对多关系
	@JoinColumn(name ="staff1Id")
	public Set<StaffRelation> getStaffRelationsOne() {
		return staffRelationsOne;
	}
	public void setStaffRelationsOne(Set<StaffRelation> staffRelationsOne) {
		this.staffRelationsOne = staffRelationsOne;
	}


	@ManyToMany(cascade=CascadeType.PERSIST,fetch = FetchType.EAGER)
	@JoinTable(
			name="circlesfollowersall",
			joinColumns={@JoinColumn(name="followerId")},
			inverseJoinColumns={@JoinColumn(name="circlesId")})
	public Set<Circles> getFollowerCircles() {
		return followerCircles;
	}

	public void setFollowerCircles(Set<Circles> followerCircles) {
		this.followerCircles = followerCircles;
	}

	@ManyToMany(cascade=CascadeType.PERSIST,fetch = FetchType.EAGER)
	@JoinTable(
			name="circlesstaffall",
			joinColumns={@JoinColumn(name="staffId")},
			inverseJoinColumns={@JoinColumn(name="circlesId")})
	public Set<Circles> getFollowStaffsCircles() {
		return followStaffsCircles;
	}

	public void setFollowStaffsCircles(Set<Circles> followStaffsCircles) {
		this.followStaffsCircles = followStaffsCircles;
	}
}
